﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Model;
using Tools;
using System.Data;
using System.Data.SqlClient;

namespace DAL
{
   public class ManageOrderDAL
    {
       public static List<BookInfo> Order()
       {
           string sql = string.Format("select Pic ,BookName,BookInfo.OriginalPrice from orders,ordersdetail,bookinfo where orders.userid=2 and orders.orderid=ordersdetail.ordersid and OrdersDetail.bookid=bookinfo.bookid");
           SqlDataReader sdr = Tools.DBHelper.ExecuteQuery(sql);
           List<BookInfo> order = new List<BookInfo>();
           while (sdr.Read())
           {
               BookInfo bo = new BookInfo();
               bo.Pic = (string)sdr["Pic"];
               bo.BookName = (string)sdr["BookName"];
               bo.OriginalPrice = (decimal)sdr["OriginalPrice"];
               order.Add(bo);
           }
           sdr.Close();
           return order;
       }
    }
}
